package test1224;

public class Test10 {
    public static void main(String[] args) {
        // 互换数组arr中最大值和最小值的位置
        int[] arr = {6, 1, 7, 4, 3};
        int a = 0;
        int b = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] >arr[a]){
                a = i;
            }
            if(arr[i] <arr[b]){
                b = i;
            }
        }
        int c = arr[a];
        arr[a] = arr[b];
        arr[b] = c;

        for (int num : arr) {
            System.out.print(num);
        }
    }
}
